﻿<ul class="unit-list blog-post">
@if((Model.Items as IEnumerable<dynamic>).Any())
{
    foreach(var i in Model.Items)
    {
        var t_post = (i.Translations as IEnumerable<dynamic>)
            .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                JDM.Int32(Svc.Localization.Language.EntityID));
        <li class="unit blog-post @(JDM.HasFlags(i.Flags, "Active") ? String.Empty : "inactive")">
            <header>
                <nav>
                    <span>@Svc.DateTimeRel((DateTime)JDM.DateTime(i.PublishedOn))</span>
                    @if(JDM.Byte(i.RatingCount) != 0 || JDM.Byte(i.CommentCount) != 0)
                    {
                        <span class="separator">&middot;</span>
                        <span>@T(Res.Name("Stat"),
                            JDM.Byte(i.RatingAverage),
                            JDM.Byte(i.RatingCount),
                            JDM.Byte(i.CommentCount))</span>
                    }
                </nav>
            </header>
            <section>
                <div class="html text-short">
                    <h3><a href="@Url.Action(Loc.Act("Show").Set(new
                    {
                        id = JDM.Int32(i.EntityID)
                    }).Localized())">@(t_post != null ? JDM.String(t_post.Title) : JDM.String(i.EntityID))</a></h3>
                    @{
                        Html.RenderPartial("_Description", (object)i);
                    }
                </div>
            </section>
            <footer>
                <nav>
                    @{
                        var tmp = i.Tags as IEnumerable<dynamic>;
                        if(tmp.Any())
                        {
                            int n = 0;
                            <span>@T(Res.Name("Tags"))</span>
                            <ul class="bar">
                            @foreach(var j in tmp)
                            {
                                var t_tag = (j.Translations as IEnumerable<dynamic>)
                                    .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                                        JDM.Int32(Svc.Localization.Language.EntityID));
                                <li><a href="@Url.Action(Loc.Act("Index").Set(new
                                {
                                    tagID = JDM.Int32(j.EntityID)
                                }).Localized())">@(t_tag != null ? JDM.String(t_tag.Name) : JDM.String(j.EntityID))</a></li>
                                if(n < tmp.Count() - 1)
                                {
                                    <li class="separator">,</li>
                                }
                                n++;
                            }
                            </ul>
                            <span class="separator">&middot;</span>
                        }
                    }
                    <a href="@Url.Action(Loc.Act("Index").Set(new
                    {
                        id = JDM.Int32(i.Author.EntityID)
                    }).Localized())">@T(Res.Name("Blog"), JDM.String(i.Author.Account.Username))</a>
                </nav>
            </footer>
        </li>
    }
}
else
{
    <li class="empty"><span>@T(Res.In("Common").Of("Expr").Name("NoData"))</span></li>
}
</ul>

